package com.team.cluedo.app.utils;



import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;

import com.team.cluedo.Game;
import com.team.cluedo.R;
import com.team.cluedo.app.PlayerCards;
import com.team.cluedo.app.PlayerFiche;
import com.team.cluedo.app.PlayerGame;
import com.team.cluedo.app.PlayerNotes;
import com.team.cluedo.app.PlayerRules;

public class CluedoMenu {
	public static final int MENU_CURRENT_GAME = 1;
	public static final int MENU_MY_CARDS = 2;
	public static final int MENU_LIST_CARDS = 3;
	public static final int MENU_NOTES = 4;
	public static final int MENU_RULES = 5;
	public static final int MENU_QUIT = 6;
	 
	 

	  public static boolean onCreateOptionsMenu(Menu menu, Activity activity) {


		  menu.add(0, MENU_CURRENT_GAME, 0, R.string.currentGame);
		  menu.add(0, MENU_MY_CARDS, 0, R.string.myCards);
		  menu.add(0, MENU_LIST_CARDS, 0, R.string.listCards);
		  menu.add(0, MENU_NOTES, 0, R.string.notes);
		  menu.add(0, MENU_RULES, 0, R.string.rules);
		  menu.add(0, MENU_QUIT, 0, R.string.quit);
		  return true;
	  }
	  
	  public static boolean onOptionsItemSelected(MenuItem item, final Activity activity) {
		  Intent defineIntent;
		  AlertDialog.Builder builder = new AlertDialog.Builder(activity);
		  builder.setMessage("Etes-vous sur de vouloir quitter la partie ?")
		         .setCancelable(false)
		         .setPositiveButton("Oui", new DialogInterface.OnClickListener() {
		             public void onClick(DialogInterface dialog, int id) {
		            	 Game.cluedo.activity.finish();
		                  activity.finish();
		             }
		         })
		         .setNegativeButton("Non", new DialogInterface.OnClickListener() {
		             public void onClick(DialogInterface dialog, int id) {
		                  dialog.cancel();
		             }
		         });
		  AlertDialog alert = builder.create();

	        switch (item.getItemId()) {
	            case MENU_CURRENT_GAME:
	            	//TODO
	            	defineIntent = new Intent(activity, PlayerGame.class);
	         		activity.startActivity(defineIntent);
	         		activity.finish();
	                return true;
	            case MENU_MY_CARDS:
	            	defineIntent = new Intent(activity,PlayerCards.class);
	            	activity.startActivity(defineIntent);
	            	activity.finish();
	                return true;
	            case MENU_LIST_CARDS:
	            	defineIntent = new Intent(activity,PlayerFiche.class);
	            	activity.startActivity(defineIntent);
	            	activity.finish();
	                return true;
	            case MENU_NOTES:
	            	defineIntent = new Intent(activity,PlayerNotes.class);
	            	activity.startActivity(defineIntent);
	            	activity.finish();
	                return true;
	            case MENU_RULES:
	            	defineIntent = new Intent(activity,PlayerRules.class);
	            	activity.startActivity(defineIntent);
	            	activity.finish();
	                return true;
	            case MENU_QUIT:
	            	alert.show();
	                return true;
	        }
	        return false;
	    }
}
